<?xml version="1.0"?><Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"><DataSources><DataSource Name="CRM"><ConnectionProperties><IntegratedSecurity>true</IntegratedSecurity><ConnectString>data source=localhost;initial catalog=Adventure_Works_Cycle_MSCRM</ConnectString><DataProvider>SQL</DataProvider></ConnectionProperties><rd:DataSourceID>bd1301de-68ad-4451-8159-73edf1a55fea</rd:DataSourceID></DataSource></DataSources><BottomMargin>0.5in</BottomMargin><RightMargin>0.5in</RightMargin><PageWidth>11in</PageWidth><ReportParameters><ReportParameter Name="CRM_FilterText"><DataType>String</DataType><Nullable>true</Nullable><AllowBlank>true</AllowBlank><Prompt>CRM_FilterText</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_FormatDate"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><DataSetReference><DataSetName>DSNumandCurrency</DataSetName><ValueField>DateFormat</ValueField></DataSetReference></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_FormatDate</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_FormatTime"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><DataSetReference><DataSetName>DSNumandCurrency</DataSetName><ValueField>TimeFormat</ValueField></DataSetReference></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_FormatDate</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_FullName"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><DataSetReference><DataSetName>UserInfo</DataSetName><ValueField>fullname</ValueField></DataSetReference></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_FullName</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_NotSpecified"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><Values><Value>Not Specified</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_NotSpecified</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_SortField"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><Values><Value>EarnedRevenue</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_SortField</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_SortDirection"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><Values><Value>Descending</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_SortDirection</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_IncludeSub"><DataType>String</DataType><DefaultValue><Values><Value>=0</Value></Values></DefaultValue><Prompt>CRM_IncludeSub</Prompt><ValidValues><ParameterValues><ParameterValue><Value>1</Value><Label>Include</Label></ParameterValue><ParameterValue><Value>0</Value><Label>Exclude</Label></ParameterValue></ParameterValues></ValidValues><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_TopAccounts"><DataType>Integer</DataType><DefaultValue><Values><Value>10</Value></Values></DefaultValue><Prompt>Top Accounts</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_GroupBy"><DataType>String</DataType><DefaultValue><Values><Value>ownerid</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>Group By</Prompt><ValidValues><ParameterValues><ParameterValue><Value>ownerid</Value><Label>Owner</Label></ParameterValue><ParameterValue><Value>accountcategorycode</Value><Label>Category</Label></ParameterValue><ParameterValue><Value>territoryid</Value><Label>Territory</Label></ParameterValue><ParameterValue><Value>industrycode</Value><Label>Industry</Label></ParameterValue><ParameterValue><Value>numberofemployees</Value><Label>No. of Employees</Label></ParameterValue><ParameterValue><Value>revenue</Value><Label>Annual Revenue</Label></ParameterValue><ParameterValue><Value>marketcap</Value><Label>Market Capitalization</Label></ParameterValue></ParameterValues></ValidValues><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_ShowAll"><DataType>String</DataType><Nullable>true</Nullable><AllowBlank>true</AllowBlank><Prompt>CRM_ShowAll</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_type"><DataType>String</DataType><Nullable>true</Nullable><AllowBlank>true</AllowBlank><Prompt>CRM_type</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_FilteredAccount"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><Values><Value>select  [account0].*  from  FilteredAccount as "account0" join (select top 1 dbo.fn_BeginOfLastXDay(GetUTCDate(), 30) as modifiedon1,GetUTCDate() as modifiedon2 order by modifiedon1,modifiedon2) as modifiedondtc on 1=1  where  ( account0.modifiedonutc &gt;= modifiedondtc.modifiedon1 and account0.modifiedonutc &lt;= modifiedondtc.modifiedon2 )</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_FilteredAccount</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_FilteredOpportunity"><DataType>String</DataType><Nullable>true</Nullable><DefaultValue><Values><Value>select  [opportunity0].*  from  FilteredOpportunity as "opportunity0" join (select top 1 dbo.fn_BeginOfLastXDay(GetUTCDate(), 30) as modifiedon1,GetUTCDate() as modifiedon2 order by modifiedon1,modifiedon2) as modifiedondtc on 1=1  where  ( opportunity0.modifiedonutc &gt;= modifiedondtc.modifiedon1 and opportunity0.modifiedonutc &lt;= modifiedondtc.modifiedon2 )</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_FilteredOpportunity</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_URL"><DataType>String</DataType><Nullable>true</Nullable><AllowBlank>true</AllowBlank><Prompt>CRM_URL</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_NumberLanguageCode"><DataType>String</DataType><DefaultValue><DataSetReference><DataSetName>DSNumandCurrency</DataSetName><ValueField>NumberLanguageCode</ValueField></DataSetReference></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_NumberLanguageCode</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_CalendarType"><DataType>String</DataType><DefaultValue><DataSetReference><DataSetName>DSNumandCurrency</DataSetName><ValueField>CalendarType</ValueField></DataSetReference></DefaultValue><Prompt>CRM_CalendarType</Prompt><Hidden>true</Hidden></ReportParameter><ReportParameter Name="CRM_UserTimeZoneName"><DataType>String</DataType><DefaultValue><Values><Value>Eastern Standard Time</Value></Values></DefaultValue><AllowBlank>true</AllowBlank><Prompt>CRM_UserTimeZoneName</Prompt><Hidden>true</Hidden></ReportParameter></ReportParameters><rd:DrawGrid>true</rd:DrawGrid><InteractiveWidth>8.5in</InteractiveWidth><rd:GridSpacing>0.03125in</rd:GridSpacing><rd:SnapToGrid>true</rd:SnapToGrid><Body><ReportItems><Rectangle Name="Bodyrectangle"><ReportItems><Rectangle Name="rectangle2xxx"><Left>6.96875in</Left><ReportItems><Textbox Name="txtGroupingCount"><Left>1.6125in</Left><Top>0.0625in</Top><ZIndex>3</ZIndex><Width>1.03125in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Format>N0</Format><Color>#666666</Color><PaddingRight>2pt</PaddingRight><FontStyle>Italic</FontStyle><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>=CountDistinct(Fields!groupbycolumn.Value, "DSAcctDistribution")</Value></Textbox><Textbox Name="txtGroupingLabel"><Left>0.03125in</Left><Top>0.0625in</Top><ZIndex>2</ZIndex><Width>1.51875in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Color>#666666</Color><PaddingRight>2pt</PaddingRight><FontStyle>Italic</FontStyle><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>=Parameters!CRM_GroupBy.Label &amp; ":"</Value></Textbox><Textbox Name="txtKBsLabel1"><Left>0.03125in</Left><Top>0.25in</Top><ZIndex>1</ZIndex><Width>1.51875in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Color>#666666</Color><PaddingRight>2pt</PaddingRight><FontStyle>Italic</FontStyle><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>Accounts:</Value></Textbox><Textbox Name="txtKBsCount1"><Left>1.6125in</Left><Top>0.25in</Top><Width>1.03125in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Format>N0</Format><Color>#666666</Color><PaddingRight>2pt</PaddingRight><FontStyle>Italic</FontStyle><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>=CountDistinct(Fields!accountid.Value.ToString(), "DSAcctDistribution")</Value></Textbox></ReportItems><Top>0.03125in</Top><ZIndex>1</ZIndex><Width>2.7375in</Width><Height>0.53125in</Height></Rectangle><Textbox Name="txtReportHeaderLabel"><Left>0.25in</Left><Top>0.03125in</Top><Width>6.51875in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>14pt</FontSize><Color>#666666</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.28125in</Height><Value>Account Distribution Detail</Value></Textbox></ReportItems><ZIndex>2</ZIndex><Width>9.875in</Width><Style><BackgroundColor>#deddcf</BackgroundColor></Style><Height>0.75in</Height></Rectangle><Table Name="table_AcctDistribution"><NoRows>=ReportItems!txtNoData.Value</NoRows><DataElementOutput>Output</DataElementOutput><DataSetName>DSAcctDistribution</DataSetName><Top>1.47in</Top><TableGroups><TableGroup><Header><TableRows><TableRow><TableCells><TableCell><ColSpan>3</ColSpan><ReportItems><Textbox Name="textbox11"><rd:DefaultName>textbox11</rd:DefaultName><ZIndex>36</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><Color>White</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Parameters!CRM_GroupBy.Label &amp; " : " &amp;  IIF( Parameters!CRM_GroupBy.Value = "revenue" or 
Parameters!CRM_GroupBy.Value = "numberofemployees" or Parameters!CRM_GroupBy.Value  ="marketcap" ,Fields!groupbycolumn.Value ,IIF (IsNothing(Fields(Parameters!CRM_GroupBy.Value).Value), Parameters!CRM_NotSpecified.Value,Fields!groupbycolumnname.Value)) &amp; " " &amp; IIF( Parameters!CRM_GroupBy.Value = "marketcap" or Parameters!CRM_GroupBy.Value = "revenue", IIF(Fields!groupbycolumn.Value  = ".5-1" or Fields!groupbycolumn.Value = "&gt;1" or Fields!groupbycolumn.Value  = "0.5-1", ReportItems!txtBil.Value,ReportItems!txtMil.Value),"")</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox14"><rd:DefaultName>textbox14</rd:DefaultName><ZIndex>35</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox16"><rd:DefaultName>textbox16</rd:DefaultName><ZIndex>34</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox17"><rd:DefaultName>textbox17</rd:DefaultName><ZIndex>33</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox18"><rd:DefaultName>textbox18</rd:DefaultName><ZIndex>32</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox19"><rd:DefaultName>textbox19</rd:DefaultName><ZIndex>31</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox20"><rd:DefaultName>textbox20</rd:DefaultName><ZIndex>30</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox21"><rd:DefaultName>textbox21</rd:DefaultName><ZIndex>29</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell><TableCell><ColSpan>7</ColSpan><ReportItems><Rectangle Name="rectangle2"><ReportItems><Textbox Name="textbox5"><Left>3.9375in</Left><Top>0.0625in</Top><ZIndex>5</ZIndex><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><Format>g</Format><Color>#5993ed</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.18375in</Height><Value>=CountDistinct( Fields!accountid.Value.ToString())</Value></Textbox><Textbox Name="txtHdrAccounts"><Left>2.75in</Left><Top>0.0625in</Top><ZIndex>4</ZIndex><Width>1.125in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><Color>#5993ed</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>Accounts</Value></Textbox><Textbox Name="txtAvgDealSizeValue"><Left>1.3425in</Left><Top>0.28125in</Top><ZIndex>3</ZIndex><Width>1.2825in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><Format>=First(Fields!CurrencyFormat_BaseCurrency_Precision.Value, "DSNumandCurrency")</Format><Color>#5993ed</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><Language>= Parameters!CRM_NumberLanguageCode.Value</Language></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>=Sum(Fields!EarnedRevenue.Value) / Sum(Fields!EarnedRevenueCount.Value)</Value></Textbox><Textbox Name="txtHdrAvgdealSize"><Top>0.28125in</Top><ZIndex>2</ZIndex><Width>1.25in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><Color>#5993ed</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>Average Opportunity Size</Value></Textbox><Textbox Name="textbox1"><Left>1.3425in</Left><Top>0.05in</Top><rd:DefaultName>textbox1</rd:DefaultName><ZIndex>1</ZIndex><Width>1.2825in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><Format>=First(Fields!CurrencyFormat_BaseCurrency_Precision.Value, "DSNumandCurrency")</Format><Color>#5993ed</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><Language>= Parameters!CRM_NumberLanguageCode.Value</Language></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>=Sum(Fields!EarnedRevenue.Value)</Value></Textbox><Textbox Name="txtHdrTotalRev"><Top>0.05in</Top><Width>1.25in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><Color>#5993ed</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.1875in</Height><Value>Earned Revenue</Value></Textbox></ReportItems><ZIndex>28</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor></Style></Rectangle></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox9"><rd:DefaultName>textbox9</rd:DefaultName><ZIndex>27</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom><Right>Solid</Right></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#2e456e</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell></TableCells><Height>0.49625in</Height></TableRow><TableRow><TableCells><TableCell><ReportItems><Textbox Name="txtname"><ZIndex>26</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="name"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="name" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Account Name</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox33"><ZIndex>25</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"name", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtowner"><ZIndex>24</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="owneridname"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="owneridname" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Owner</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox35"><ZIndex>23</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"owneridname", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtcity"><ZIndex>22</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="address1_city"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="address1_city" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>City</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox37"><ZIndex>21</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"address1_city", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtstate"><ZIndex>20</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="address1_stateorprovince"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="address1_stateorprovince" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>State</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox39"><ZIndex>19</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"address1_stateorprovince", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtterritory"><ZIndex>18</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="territoryidname"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="territoryidname" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><TextAlign>Left</TextAlign><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Territory</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox41"><ZIndex>17</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"territoryidname", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtcategory"><ZIndex>16</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="accountcategorycodename"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="accountcategorycodename" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Category</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox43"><ZIndex>15</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"accountcategorycodename", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtindustry"><ZIndex>14</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="industrycodename"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="industrycodename" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Industry</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox45"><ZIndex>13</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"industrycodename", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtearnedrev"><ZIndex>12</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="EarnedRevenue"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="EarnedRevenue" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Earned Revenue</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox47"><ZIndex>11</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"EarnedRevenue", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="txtavgdeal"><ZIndex>10</ZIndex><Action><Drillthrough><ReportName>Account Distribution Detail</ReportName><Parameters><Parameter Name="CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></Parameter><Parameter Name="CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></Parameter><Parameter Name="CRM_FilterText"><Value>=Parameters!CRM_FilterText.Value</Value></Parameter><Parameter Name="CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></Parameter><Parameter Name="CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></Parameter><Parameter Name="CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></Parameter><Parameter Name="CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></Parameter><Parameter Name="CRM_type"><Value>=Parameters!CRM_type.Value</Value></Parameter><Parameter Name="CRM_SortField"><Value>="EarnedRevenue"</Value></Parameter><Parameter Name="CRM_SortDirection"><Value>=IIF(Parameters!CRM_SortField.Value="AverageDealSize" And Parameters!CRM_SortDirection.Value = "Ascending", "Descending", "Ascending")</Value></Parameter><Parameter Name="CRM_UserTimeZoneName"><Value>=Parameters!CRM_UserTimeZoneName.Value</Value></Parameter></Parameters></Drillthrough></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>Average Deal Size</Value></Textbox></ReportItems></TableCell><TableCell><ReportItems><Textbox Name="textbox49"><ZIndex>9</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom><Right>Solid</Right></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>symbol</FontFamily><FontWeight>700</FontWeight><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><BackgroundColor>#e9e9e9</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Microsoft.Crm.Reporting.RdlHelper.ReportUtility.GetArrow(Parameters!CRM_SortField.Value,"EarnedRevenue", Parameters!CRM_SortDirection.Value)</Value></Textbox></ReportItems></TableCell></TableCells><Height>0.25in</Height></TableRow></TableRows></Header><Sorting><SortBy><SortExpression>=IIF( Parameters!CRM_GroupBy.Value = "revenue" or Parameters!CRM_GroupBy.Value = "marketcap" or Parameters!CRM_GroupBy.Value = "numberofemployees", Fields!categorynumber.Value,Sum(Fields!EarnedRevenue.Value))</SortExpression><Direction>Descending</Direction></SortBy></Sorting><Grouping Name="table_AcctDistribution_Group1"><GroupExpressions><GroupExpression>=IIF( Parameters!CRM_GroupBy.Value = "numberofemployees" or Parameters!CRM_GroupBy.Value = "revenue" or Parameters!CRM_GroupBy.Value = "marketcap" ,Fields!groupbycolumn.Value,IIF(IsNothing(Fields!groupbycolumn.Value), Parameters!CRM_NotSpecified.Value ,Fields!groupbycolumn.Value))</GroupExpression></GroupExpressions></Grouping></TableGroup></TableGroups><ZIndex>1</ZIndex><Width>9.86861in</Width><Details><TableRows><TableRow><TableCells><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="name"><rd:DefaultName>name</rd:DefaultName><ZIndex>8</ZIndex><Action><Hyperlink>=IIF(IsNothing(Parameters!CRM_URL.Value),Nothing,Parameters!CRM_URL.Value &amp; "?ID={"&amp;Fields!accountid.Value.ToString()&amp;"}&amp;OTC=1")</Hyperlink></Action><Style><BorderStyle><Bottom>Solid</Bottom><Left>Solid</Left></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!name.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="owneridname"><rd:DefaultName>owneridname</rd:DefaultName><ZIndex>7</ZIndex><Action><Hyperlink>=IIF(IsNothing(Parameters!CRM_URL.Value),Nothing,Parameters!CRM_URL.Value &amp; "?ID={"&amp;Fields!ownerid.Value.ToString()&amp;"}&amp;OTC=8")</Hyperlink></Action><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!owneridname.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="address1_city"><rd:DefaultName>address1_city</rd:DefaultName><ZIndex>6</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!address1_city.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="address1_stateorprovince"><rd:DefaultName>address1_stateorprovince</rd:DefaultName><ZIndex>5</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!address1_stateorprovince.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="territoryidname"><rd:DefaultName>territoryidname</rd:DefaultName><ZIndex>4</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><TextAlign>Left</TextAlign><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!territoryidname.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="accountcategorycodename"><rd:DefaultName>accountcategorycodename</rd:DefaultName><ZIndex>3</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!accountcategorycodename.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="industrycodename"><rd:DefaultName>industrycodename</rd:DefaultName><ZIndex>2</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value>=Fields!industrycodename.Value</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="EarnedRevenue"><rd:DefaultName>EarnedRevenue</rd:DefaultName><ZIndex>1</ZIndex><Style><BorderStyle><Bottom>Solid</Bottom></BorderStyle><TextAlign>Right</TextAlign><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><Format>=First(Fields!CurrencyFormat_BaseCurrency_Precision.Value, "DSNumandCurrency")</Format><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><Language>= Parameters!CRM_NumberLanguageCode.Value</Language></Style><CanGrow>true</CanGrow><Value>=Sum(Fields!EarnedRevenue.Value)</Value></Textbox></ReportItems></TableCell><TableCell><ColSpan>2</ColSpan><ReportItems><Textbox Name="AverageDealSize"><rd:DefaultName>AverageDealSize</rd:DefaultName><Style><BorderStyle><Bottom>Solid</Bottom><Right>Solid</Right></BorderStyle><TextAlign>Right</TextAlign><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>7.5pt</FontSize><Format>=First(Fields!CurrencyFormat_BaseCurrency_Precision.Value, "DSNumandCurrency")</Format><BorderColor><Default>#adadad</Default></BorderColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><Language>= Parameters!CRM_NumberLanguageCode.Value</Language></Style><CanGrow>true</CanGrow><Value>=Sum(Fields!EarnedRevenue.Value)/Sum(Fields!EarnedRevenueCount.Value)</Value></Textbox></ReportItems></TableCell></TableCells><Height>0.32292in</Height></TableRow></TableRows><Grouping Name="table_AcctDistribution_Details_Group"><GroupExpressions><GroupExpression>=Fields!accountid.Value.ToString()</GroupExpression></GroupExpressions></Grouping><Sorting><SortBy><SortExpression>=IIF(Parameters!CRM_SortDirection.Value="Ascending", Fields(Parameters!CRM_SortField.Value).Value, "")</SortExpression><Direction>Ascending</Direction></SortBy><SortBy><SortExpression>=IIF(Parameters!CRM_SortDirection.Value="Descending", Fields(Parameters!CRM_SortField.Value).Value, "")</SortExpression><Direction>Descending</Direction></SortBy></Sorting></Details><TableColumns><TableColumn><Width>0.96875in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>0.78125in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>0.71875in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>0.34375in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>0.625in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>1.58333in</Width></TableColumn><TableColumn><Width>0.25in</Width></TableColumn><TableColumn><Width>0.78125in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>0.90625in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn><TableColumn><Width>0.875in</Width></TableColumn><TableColumn><Width>0.25441in</Width></TableColumn></TableColumns></Table><Rectangle Name="rectFilterSummary"><ReportItems><Textbox Name="txtNoData"><Left>7.96875in</Left><Top>0.3125in</Top><ZIndex>7</ZIndex><Visibility><Hidden>true</Hidden></Visibility><Width>0.71875in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><BackgroundColor>Yellow</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.15625in</Height><Value>No Account Data</Value></Textbox><Textbox Name="txtDollar"><Left>7.34375in</Left><Top>0.03125in</Top><ZIndex>6</ZIndex><Visibility><Hidden>true</Hidden></Visibility><Width>0.59375in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><BackgroundColor>Yellow</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.15625in</Height><Value>$</Value></Textbox><Textbox Name="txtBil"><Left>8in</Left><ZIndex>5</ZIndex><Visibility><Hidden>true</Hidden></Visibility><Width>0.75in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><BackgroundColor>Yellow</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.15625in</Height><Value>Bil.</Value></Textbox><Textbox Name="txtMil"><Left>6.53125in</Left><Top>0.03125in</Top><ZIndex>4</ZIndex><Visibility><Hidden>true</Hidden></Visibility><Width>0.625in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><BackgroundColor>Yellow</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.15625in</Height><Value>Mil.</Value></Textbox><Textbox Name="txtFilterSummaryValue"><Left>0.25in</Left><Top>0.325in</Top><ZIndex>3</ZIndex><Visibility><ToggleItem>txtFilterSummary</ToggleItem><Hidden>true</Hidden></Visibility><Width>5.53125in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontSize>8pt</FontSize><Color>#313336</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.25in</Height><Value>=Parameters!CRM_FilterText.Value</Value></Textbox><Textbox Name="txtFilterSummary"><Left>0.25in</Left><Top>0.03125in</Top><ZIndex>2</ZIndex><Width>5.53125in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>12pt</FontSize><Color>#313336</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.25in</Height><Value>Filter Summary</Value></Textbox><Table Name="table1"><Left>6.84375in</Left><DataElementOutput>Output</DataElementOutput><DataSetName>DSNumandCurrency</DataSetName><Top>0.3125in</Top><ZIndex>1</ZIndex><Visibility><Hidden>true</Hidden></Visibility><Width>0.8125in</Width><Details><TableRows><TableRow><TableCells><TableCell><ReportItems><Textbox Name="textbox15"><rd:DefaultName>textbox15</rd:DefaultName><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Value /></Textbox></ReportItems></TableCell></TableCells><Height>0.08333in</Height></TableRow></TableRows></Details><TableColumns><TableColumn><Width>0.8125in</Width></TableColumn></TableColumns><Height>0.08333in</Height></Table><Textbox Name="txtBilorMil"><Left>7.34375in</Left><Top>0.0625in</Top><Visibility><Hidden>true</Hidden></Visibility><Width>0.59375in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><BackgroundColor>Yellow</BackgroundColor><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.15625in</Height><Value>=IIF( Parameters!CRM_GroupBy.Value = "marketcap" or Parameters!CRM_GroupBy.Value = "revenue", IIF(First(Fields!groupbycolumn.Value, "DSAcctDistribution")  = "500-1" or First(Fields!groupbycolumn.Value, "DSAcctDistribution") = "&gt;1", ReportItems!txtBil.Value,ReportItems!txtMil.Value),"")</Value></Textbox></ReportItems><Top>0.772in</Top><Visibility><Hidden>=IIF(IsNothing(Parameters!CRM_FilterText.Value) or (Parameters!CRM_FilterText.Value) = "" or (Parameters!CRM_FilterText.Value) = " " , True, False)</Hidden></Visibility><Width>9.875in</Width><Style><BackgroundColor>#deddcf</BackgroundColor></Style><Height>0.6685in</Height></Rectangle></ReportItems><Height>2.53917in</Height></Body><rd:ReportID>175a60d8-7f95-49ba-b4f6-a498c1c36244</rd:ReportID><LeftMargin>0.5in</LeftMargin><DataSets><DataSet Name="UserInfo"><Query><rd:UseGenericDesigner>true</rd:UseGenericDesigner><CommandText>select fullname from FilteredSystemUser where systemuserid = dbo.fn_FindUserGuid()</CommandText><DataSourceName>CRM</DataSourceName></Query><Fields><Field Name="fullname"><rd:TypeName>System.String</rd:TypeName><DataField>fullname</DataField></Field></Fields></DataSet><DataSet Name="DSNumandCurrency"><Query><rd:UseGenericDesigner>true</rd:UseGenericDesigner><CommandText>select * from dbo.fn_GetFormatStrings()</CommandText><DataSourceName>CRM</DataSourceName></Query><Fields><Field Name="DateFormat"><rd:TypeName>System.String</rd:TypeName><DataField>DateFormat</DataField></Field><Field Name="TimeFormat"><rd:TypeName>System.String</rd:TypeName><DataField>TimeFormat</DataField></Field><Field Name="NumberLanguageCode"><rd:TypeName>System.String</rd:TypeName><DataField>NumberLanguageCode</DataField></Field><Field Name="CalendarType"><rd:TypeName>System.String</rd:TypeName><DataField>CalendarType</DataField></Field><Field Name="NumberFormat_0_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>NumberFormat_0_Precision</DataField></Field><Field Name="NumberFormat_1_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>NumberFormat_1_Precision</DataField></Field><Field Name="NumberFormat_2_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>NumberFormat_2_Precision</DataField></Field><Field Name="NumberFormat_3_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>NumberFormat_3_Precision</DataField></Field><Field Name="NumberFormat_4_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>NumberFormat_4_Precision</DataField></Field><Field Name="NumberFormat_5_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>NumberFormat_5_Precision</DataField></Field><Field Name="CurrencyFormat_0_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_0_Precision</DataField></Field><Field Name="CurrencyFormat_1_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_1_Precision</DataField></Field><Field Name="CurrencyFormat_2_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_2_Precision</DataField></Field><Field Name="CurrencyFormat_3_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_3_Precision</DataField></Field><Field Name="CurrencyFormat_4_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_4_Precision</DataField></Field><Field Name="CurrencyFormat_5_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_5_Precision</DataField></Field><Field Name="CurrencyFormat_BaseCurrency_Precision"><rd:TypeName>System.String</rd:TypeName><DataField>CurrencyFormat_BaseCurrency_Precision</DataField></Field></Fields></DataSet><DataSet Name="DSAcctDistribution"><Query><rd:UseGenericDesigner>true</rd:UseGenericDesigner><CommandText>DECLARE @SQL nVarchar(max) DECLARE @SQL1 nVarchar(max) DECLARE @SQL2 nVarchar(max) DECLARE @SQL3 nVarchar(max) 
DECLARE @SQL4 nVarchar(max) DECLARE @SQL5 nVarchar(max) DECLARE @SQL6 nVarchar(max) DECLARE @GroupByCol nVarchar(40) 
DECLARE @joinstr nVarchar(max) DECLARE @joinstr2 nVarchar(max) DECLARE @Groupbyidcoltype nvarchar(100) DECLARE @codestr nVarchar(40) 
DECLARE @groupbycolname nVarchar(40) DECLARE @groupbyname nvarchar(200) IF @CRM_GroupBy = 'ownerid' BEGIN
SET              @GroupByCol = 'tn.ownerid'
SET              @groupbyname = 'tn.owneridname'
SET              @Groupbyidcoltype = 'nVarchar(60)'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = '''',''categorynumber'' = ''''
from FilteredAccount) as qq on (ci.ParentId = qq.accountid) '
SET              @joinstr2 = ''
SET              @codestr = 'aa.ownerid'
SET              @groupbycolname = 'att.owneridname' END IF @CRM_GroupBy = 'accountcategorycode' BEGIN
SET              @Groupbyidcoltype = 'nVarchar(60)'
SET              @GroupByCol = 'tn.accountcategorycode'
SET              @groupbyname = 'tn.accountcategorycodename'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = '''',''categorynumber'' = ''''
from FilteredAccount) as qq on (att.accountid = qq.accountid) '
SET              @joinstr2 = ''
SET              @codestr = 'aa.accountcategorycode'
SET              @groupbycolname = 'att.accountcategorycodename' END IF @CRM_GroupBy = 'territoryid' BEGIN
SET              @Groupbyidcoltype = 'nVarchar(60)'
SET              @GroupByCol = 'tn.territoryid'
SET              @groupbyname = 'tn.territoryidname'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = '''',''categorynumber'' = ''''
from FilteredAccount) as qq on (att.accountid = qq.accountid) '
SET              @joinstr2 = ''
SET              @codestr = 'aa.territoryid'
SET              @groupbycolname = 'att.territoryidname' END IF @CRM_GroupBy = 'industrycode' BEGIN
SET              @Groupbyidcoltype = 'nVarchar(60)'
SET              @GroupByCol = 'tn.industrycode'
SET              @groupbyname = 'tn.industrycodename'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = '''',''categorynumber'' = ''''
from FilteredAccount) as qq on (att.accountid = qq.accountid) '
SET              @joinstr2 = ''
SET              @codestr = 'aa.industrycode'
SET              @groupbycolname = 'att.industrycodename' END IF @CRM_GroupBy = 'numberofemployees' BEGIN
SET              @Groupbyidcoltype = 'nvarchar(60)'
SET              @GroupByCol = 'qq.category'
SET              @groupbyname = 'qq.category'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = Case 
        When ''' + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &lt; 10) then ''&lt;10''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 10 and IsNull(numberofemployees, 0) &lt;= 49 )then ''10-49''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 50   and IsNull(numberofemployees, 0) &lt;= 99) then ''50-99''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 100  and IsNull(numberofemployees, 0) &lt;= 499) then ''100-499''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 1000) then ''500-1000''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 4999) then ''1000-4999''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 5000) then ''&gt;5000'' end,
''categorynumber'' = Case 
        When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &lt; 10) then 7
                When ''' + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 10 and IsNull(numberofemployees, 0) &lt;= 49 )then 6
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 50   and IsNull(numberofemployees, 0) &lt;= 99) then 5
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 100  and IsNull(numberofemployees, 0) &lt;= 499) then 4
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 1000) then 3
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 4999) then 2
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 5000) then 1 end
from FilteredAccount) as qq on (ci.ParentId = qq.accountid) '
SET              @joinstr2 = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = Case 
        When ''' + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &lt; 10) then ''&lt;10''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 10 and IsNull(numberofemployees, 0) &lt;= 49 )then ''10-49''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 50   and IsNull(numberofemployees, 0) &lt;= 99) then ''50-99''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 100  and IsNull(numberofemployees, 0) &lt;= 499) then ''100-499''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 1000) then ''500-1000''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 4999) then ''1000-4999''
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 5000) then ''&gt;5000'' end,
''categorynumber'' = Case 
        When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &lt; 10) then 7
                When ''' + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 10 and IsNull(numberofemployees, 0) &lt;= 49 )then 6
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 50   and IsNull(numberofemployees, 0) &lt;= 99) then 5
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 100  and IsNull(numberofemployees, 0) &lt;= 499) then 4
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 1000) then 3
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 500  and IsNull(numberofemployees, 0) &lt;= 4999) then 2
                When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'') and (IsNull(numberofemployees, 0) &gt;= 5000) then 1 end
from FilteredAccount) as qq on (tn.accountid = qq.accountid) '
SET              @codestr = 'groupbycolumn'
SET              @groupbycolname = 'qq.category' END IF @CRM_GroupBy = 'revenue' BEGIN
SET              @GroupByCol = 'qq.category'
SET              @groupbyname = 'qq.category'
SET              @Groupbyidcoltype = 'nvarchar(60)'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = Case 
        When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &lt; 5000000) then ''&lt;5''
                When '''
                       + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= 5000000 and IsNull(revenue_base, 0) &lt;= (1000000*25)) then ''5-25''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*25)   and IsNull(revenue_base, 0) &lt;= (1000000*50)) then ''25-50''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*50)  and IsNull(revenue_base, 0) &lt;= (1000000*250)) then ''50-250''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*250) and IsNull(revenue_base, 0) &lt;= (1000000*500)) then ''250-500''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*500) and IsNull(revenue_base, 0) &lt;=  (1000000*1000)) then ''0.5-1''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt; (1000000*1000)) then ''&gt;1'' end,
''categorynumber'' = Case 
                When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &lt; 5000000) then 7
                When '''
                       + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= 5000000 and IsNull(revenue_base, 0) &lt;= (1000000*25)) then 6
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*25)   and IsNull(revenue_base, 0) &lt;= (1000000*50)) then 5
                When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*50)  and IsNull(revenue_base, 0) &lt;= (1000000*250)) then 4
                When '''
                       + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*250) and IsNull(revenue_base, 0) &lt;= (1000000*500)) then 3
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*500) and IsNull(revenue_base, 0) &lt;=  (1000000*1000)) then 2
                When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt; (1000000*1000)) then 1 end
from FilteredAccount) as qq on (ci.ParentId = qq.accountid) '
SET              @joinstr2 = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = Case 
        When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &lt; 5000000) then ''&lt;5''
                When '''
                       + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= 5000000 and IsNull(revenue_base, 0) &lt;= (1000000*25)) then ''5-25''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*25)   and IsNull(revenue_base, 0) &lt;= (1000000*50)) then ''25-50''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*50)  and IsNull(revenue_base, 0) &lt;= (1000000*250)) then ''50-250''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*250) and IsNull(revenue_base, 0) &lt;= (1000000*500)) then ''250-500''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*500) and IsNull(revenue_base, 0) &lt;=  (1000000*1000)) then ''0.5-1''
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt; (1000000*1000)) then ''&gt;1'' end,
''categorynumber'' = Case 
                When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &lt; 5000000) then 7
                When '''
                       + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= 5000000 and IsNull(revenue_base, 0) &lt;= (1000000*25)) then 6
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*25)   and IsNull(revenue_base, 0) &lt;= (1000000*50)) then 5
                When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*50)  and IsNull(revenue_base, 0) &lt;= (1000000*250)) then 4
                When '''
                       + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*250) and IsNull(revenue_base, 0) &lt;= (1000000*500)) then 3
                When ''' + @CRM_GroupBy
                       + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt;= (1000000*500) and IsNull(revenue_base, 0) &lt;=  (1000000*1000)) then 2
                When ''' + @CRM_GroupBy + ''' in (''revenue'') and (IsNull(revenue_base, 0) &gt; (1000000*1000)) then 1 end
from FilteredAccount) as qq on (tn.accountid = qq.accountid) '
SET              @codestr = 'groupbycolumn'
SET              @groupbycolname = 'qq.category' END IF @CRM_GroupBy = 'marketcap' BEGIN
SET              @GroupByCol = 'qq.category'
SET              @groupbyname = 'qq.category'
SET              @Groupbyidcoltype = 'nvarchar(60)'
SET              @joinstr = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = Case 
        When ''' + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &lt;= 5000000) then ''&lt;5''                 
        When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= 5000000 and IsNull(marketcap_base, 0) &lt;= (1000000*25)) then ''5-25''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*25)   and IsNull(marketcap_base, 0) &lt;= (1000000*50)) then ''25-50''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*50)  and IsNull(marketcap_base, 0) &lt;= (1000000*250)) then ''50-250''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*250) and IsNull(marketcap_base, 0) &lt;= (1000000*500)) then ''250-500''
                when '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*500) and IsNull(marketcap_base, 0) &lt;= (1000000*1000)) then ''0.5-1''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt; (1000000*1000)) then ''&gt;1'' end,
''categorynumber'' = Case 
                When ''' + @CRM_GroupBy
                       + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &lt;= 5000000) then 7                 
        When ''' + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= 5000000 and IsNull(marketcap_base, 0) &lt;= (1000000*25)) then 6
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*25)   and IsNull(marketcap_base, 0) &lt;= (1000000*50)) then 5
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*50)  and IsNull(marketcap_base, 0) &lt;= (1000000*250)) then 4
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*250) and IsNull(marketcap_base, 0) &lt;= (1000000*500)) then 3
                when '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*500) and IsNull(marketcap_base, 0) &lt;= (1000000*1000)) then 2
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt; (1000000*1000)) then 1 end
from FilteredAccount) as qq on (ci.ParentId = qq.accountid) '
SET              @joinstr2 = 'join (select accountid, ' + @CRM_GroupBy + ',
 ''category'' = Case 
        When ''' + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &lt;= 5000000) then ''&lt;5''                 
        When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= 5000000 and IsNull(marketcap_base, 0) &lt;= (1000000*25)) then ''5-25''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*25)   and IsNull(marketcap_base, 0) &lt;= (1000000*50)) then ''25-50''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*50)  and IsNull(marketcap_base, 0) &lt;= (1000000*250)) then ''50-250''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*250) and IsNull(marketcap_base, 0) &lt;= (1000000*500)) then ''250-500''
                when '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*500) and IsNull(marketcap_base, 0) &lt;= (1000000*1000)) then ''0.5-1''
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt; (1000000*1000)) then ''&gt;1'' end,
''categorynumber'' = Case 
                When ''' + @CRM_GroupBy
                       + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &lt;= 5000000) then 7                 
        When ''' + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= 5000000 and IsNull(marketcap_base, 0) &lt;= (1000000*25)) then 6
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*25)   and IsNull(marketcap_base, 0) &lt;= (1000000*50)) then 5
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*50)  and IsNull(marketcap_base, 0) &lt;= (1000000*250)) then 4
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*250) and IsNull(marketcap_base, 0) &lt;= (1000000*500)) then 3
                when '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt;= (1000000*500) and IsNull(marketcap_base, 0) &lt;= (1000000*1000)) then 2
                When '''
                       + @CRM_GroupBy + ''' in (''marketcap'') and (IsNull(marketcap_base, 0) &gt; (1000000*1000)) then 1 end
from FilteredAccount) as qq on (tn.accountid = qq.accountid) '
SET              @codestr = 'groupbycolumn'
SET              @groupbycolname = 'qq.category' END CREATE TABLE #CustomerIds(ParentId uniqueidentifier, 
                      ChildId uniqueidentifier PRIMARY KEY CLUSTERED ([ParentId], [ChildId])) CREATE STATISTICS rupactbatchstat ON #CustomerIds(ParentId, ChildId)
SET              @SQL = '
insert into #CustomerIds 
select accountid,accountid from (' + @CRM_FilteredAccount + ') as acct ' EXEC (@SQL) 
                      DECLARE @AcctDepth int DECLARE @ContactDepth int
SET              @AcctDepth = 3
SET              @ContactDepth = 3 EXEC p_AccountDistRollup @CRM_IncludeSub, @AcctDepth, 1, @ContactDepth
SET              @SQL1 = '
Declare @TopN Table(accountid uniqueidentifier,estamount float, 
                    EarnedRevenueCount int, acctcount int,
                    name nVarchar(max),
                    owneridname nVarchar(max), ownerid uniqueidentifier,
                    numberofemployees int,revenue float,revenue_base float,marketcap float,marketcap_base float,crm_moneyformatstring nvarchar(255),
                    address1_city nVarchar(max),address1_stateorprovince nVarchar(max),
                    territoryid uniqueidentifier,territoryidname nVarchar(max),
                    accountcategorycodename nVarchar(max), industrycodename nvarchar(max),
                    accountcategorycode int, industrycode int,
                    categorynumber int, groupbycolumn nVarchar(max),groupbycolumnname nvarchar(max)
                     ) 

Insert into @TopN
Select Top '
                       + CONVERT(VarChar(10), @CRM_TopAccounts) 
                      + ' ci.ParentId ,Sum(IsNull(o.actualvalue_base,0)) as estamount,
count(*) as EarnedRevenueCount, 1 as acctcount,
att.name,att.owneridname,att.ownerid,att.numberofemployees,att.revenue,att.revenue_base,att.marketcap,att.marketcap_base,att.crm_moneyformatstring,
att.address1_city,att.address1_stateorprovince,att.territoryid,att.territoryidname,
att.accountcategorycodename,att.industrycodename,att.accountcategorycode,att.industrycode,
''categorynumber'' = Case 
            When '''
                       + @CRM_GroupBy + ''' not in (''numberofemployees'',''revenue'',''marketcap'') then
                0
        When ''' + @CRM_GroupBy + ''' in (''numberofemployees'',''revenue'',''marketcap'') then 
                      qq.categorynumber
                     end,
''groupbycolumn'' =  Case 
            When '''
                       + @CRM_GroupBy + ''' not in (''numberofemployees'',''revenue'',''marketcap'') then
                Convert(nVarchar(400), att.' + @CRM_GroupBy + ')
        When '''
                       + @CRM_GroupBy + ''' in (''numberofemployees'',''revenue'',''marketcap'') then qq.category
                     end,
' + @groupbycolname + ' as groupbycolumnname
from #CustomerIds ci
join ('
                       + @CRM_FilteredAccount + ') att on (att.accountid = ci.ParentId)
join (' + @CRM_FilteredOpportunity + ') o on (ci.ChildId = o.customerid)
'
SET              @SQL2 = '
' + @joinstr + '
where o.statecode = 1 and o.actualvalue &gt; 0
Group By ci.ParentId,att.name,att.owneridname,att.ownerid,att.numberofemployees,att.revenue,att.revenue_base,att.marketcap,att.marketcap_base,att.crm_moneyformatstring,
att.address1_city,att.address1_stateorprovince,att.territoryid,att.territoryidname,
att.accountcategorycodename,att.industrycodename,att.accountcategorycode,att.industrycode,
qq.categorynumber,qq.category
order by Sum(o.actualvalue) desc 
'
SET              @SQL3 = 'Declare @Top15 Table(groupbyid ' + @Groupbyidcoltype + ', estamount float,gcount int)

Insert into @Top15 
Select top 15 IsNull(Cast(' + @GroupByCol
                       + ' as nvarchar(60)),''_CRM_NOTSPECIFIED'') as groupbyid,
        Sum(tn.estamount) as estamount,1 as gcount
from @TopN tn
' + @joinstr2 + ' '
SET              @SQL4 = '
Group By IsNull(Cast(' + @GroupByCol + ' as nvarchar(60)),''_CRM_NOTSPECIFIED''),' + @groupbyname + '
order by Sum(tn.estamount) desc ,'
                       + @groupbyname + '


Declare @total float
Select @total = Sum(estamount) FROM @TopN
Declare @count int
Select @count = Sum(acctcount) FROM @TopN '
                       IF @CRM_ShowAll = 'showall' BEGIN
SET              @SQL5 = 'select * from (
select accountid,name,owneridname,ownerid,numberofemployees,revenue,revenue_base,marketcap,marketcap_base,crm_moneyformatstring,
address1_city,address1_stateorprovince,territoryidname,accountcategorycodename,industrycodename,categorynumber,
 estamount as EarnedRevenue,EarnedRevenueCount,groupbycolumn,groupbycolumnname,
territoryid,accountcategorycode,industrycode
from @TopN tn )  as aa
Where '''
                       + @CRM_ShowAll + ''' = ''showall'' ' END IF @CRM_type = '_CRM_NOTSPECIFIED' BEGIN
SET              @SQL5 = 'select * from (
select accountid,name,owneridname,ownerid,numberofemployees,revenue,revenue_base,marketcap,marketcap_base,crm_moneyformatstring,
address1_city,address1_stateorprovince,territoryidname,accountcategorycodename,industrycodename,categorynumber,
 estamount as EarnedRevenue,EarnedRevenueCount,groupbycolumn,groupbycolumnname,
territoryid,accountcategorycode,industrycode
from @TopN tn ) as aa
Where ( '''
                       + @CRM_type + ''' = ''_CRM_NOTSPECIFIED'' and groupbycolumn is null)' END IF @CRM_type = '_CRM_OTHER' BEGIN
SET              @SQL5 = 'select * from (
select accountid,name,owneridname,ownerid,numberofemployees,revenue,revenue_base,marketcap,marketcap_base,crm_moneyformatstring,
address1_city,address1_stateorprovince,territoryidname,accountcategorycodename,industrycodename,categorynumber,
 estamount as EarnedRevenue,EarnedRevenueCount,groupbycolumn,groupbycolumnname,
territoryid,accountcategorycode,industrycode
from @TopN tn where
 IsNull(Cast('
                       + @GroupByCol + ' as nvarchar(60)),''_CRM_NOTSPECIFIED'')
 not in (select groupbyid from @Top15)) as aa ' END IF (@CRM_type NOT IN ('_CRM_NOTSPECIFIED',
                       '_CRM_OTHER') AND @CRM_type IS NOT NULL) BEGIN
SET              @SQL5 = 'select * from (
select accountid,name,owneridname,ownerid,numberofemployees,revenue,revenue_base,marketcap,marketcap_base,crm_moneyformatstring,
address1_city,address1_stateorprovince,territoryidname,accountcategorycodename,industrycodename,categorynumber,
 estamount as EarnedRevenue,EarnedRevenueCount,groupbycolumn,groupbycolumnname,
territoryid,accountcategorycode,industrycode
from @TopN tn ) as aa
Where ( '''
                       + @CRM_type + ''' &lt;&gt; ''_CRM_NOTSPECIFIED'' and 
' + @codestr + ' = ''' + @CRM_type + ''')' END EXEC (@SQL1 + @SQL2 + @SQL3 + @SQL4 + @SQL5)
                       DROP TABLE #CustomerIds</CommandText><QueryParameters><QueryParameter Name="@CRM_GroupBy"><Value>=Parameters!CRM_GroupBy.Value</Value></QueryParameter><QueryParameter Name="@CRM_FilteredAccount"><Value>=Parameters!CRM_FilteredAccount.Value</Value></QueryParameter><QueryParameter Name="@CRM_IncludeSub"><Value>=Parameters!CRM_IncludeSub.Value</Value></QueryParameter><QueryParameter Name="@CRM_TopAccounts"><Value>=Parameters!CRM_TopAccounts.Value</Value></QueryParameter><QueryParameter Name="@CRM_FilteredOpportunity"><Value>=Parameters!CRM_FilteredOpportunity.Value</Value></QueryParameter><QueryParameter Name="@CRM_ShowAll"><Value>=Parameters!CRM_ShowAll.Value</Value></QueryParameter><QueryParameter Name="@CRM_type"><Value>=Parameters!CRM_type.Value</Value></QueryParameter></QueryParameters><DataSourceName>CRM</DataSourceName></Query><Fields><Field Name="accountid"><rd:TypeName>System.Guid</rd:TypeName><DataField>accountid</DataField></Field><Field Name="name"><rd:TypeName>System.String</rd:TypeName><DataField>name</DataField></Field><Field Name="owneridname"><rd:TypeName>System.String</rd:TypeName><DataField>owneridname</DataField></Field><Field Name="ownerid"><rd:TypeName>System.Guid</rd:TypeName><DataField>ownerid</DataField></Field><Field Name="numberofemployees"><rd:TypeName>System.Int32</rd:TypeName><DataField>numberofemployees</DataField></Field><Field Name="revenue"><rd:TypeName>System.Double</rd:TypeName><DataField>revenue</DataField></Field><Field Name="revenue_base"><rd:TypeName>System.Double</rd:TypeName><DataField>revenue_base</DataField></Field><Field Name="marketcap"><rd:TypeName>System.Double</rd:TypeName><DataField>marketcap</DataField></Field><Field Name="marketcap_base"><rd:TypeName>System.Double</rd:TypeName><DataField>marketcap_base</DataField></Field><Field Name="crm_moneyformatstring"><rd:TypeName>System.String</rd:TypeName><DataField>crm_moneyformatstring</DataField></Field><Field Name="address1_city"><rd:TypeName>System.String</rd:TypeName><DataField>address1_city</DataField></Field><Field Name="address1_stateorprovince"><rd:TypeName>System.String</rd:TypeName><DataField>address1_stateorprovince</DataField></Field><Field Name="territoryidname"><rd:TypeName>System.String</rd:TypeName><DataField>territoryidname</DataField></Field><Field Name="accountcategorycodename"><rd:TypeName>System.String</rd:TypeName><DataField>accountcategorycodename</DataField></Field><Field Name="industrycodename"><rd:TypeName>System.String</rd:TypeName><DataField>industrycodename</DataField></Field><Field Name="categorynumber"><rd:TypeName>System.Int32</rd:TypeName><DataField>categorynumber</DataField></Field><Field Name="EarnedRevenue"><rd:TypeName>System.Double</rd:TypeName><DataField>EarnedRevenue</DataField></Field><Field Name="EarnedRevenueCount"><rd:TypeName>System.Int32</rd:TypeName><DataField>EarnedRevenueCount</DataField></Field><Field Name="groupbycolumn"><rd:TypeName>System.String</rd:TypeName><DataField>groupbycolumn</DataField></Field><Field Name="groupbycolumnname"><rd:TypeName>System.String</rd:TypeName><DataField>groupbycolumnname</DataField></Field><Field Name="territoryid"><rd:TypeName>System.Guid</rd:TypeName><DataField>territoryid</DataField></Field><Field Name="accountcategorycode"><rd:TypeName>System.Int32</rd:TypeName><DataField>accountcategorycode</DataField></Field><Field Name="industrycode"><rd:TypeName>System.Int32</rd:TypeName><DataField>industrycode</DataField></Field></Fields></DataSet></DataSets><Author> MSFT</Author><Width>9.96875in</Width><InteractiveHeight>11in</InteractiveHeight><Language>=Parameters!CRM_NumberLanguageCode.Value</Language><PageFooter><ReportItems><Textbox Name="txtPageCount"><Left>7.59375in</Left><ZIndex>2</ZIndex><Style><TextAlign>Right</TextAlign><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontFamily>tahoma</FontFamily><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Color>#666666</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.21875in</Height><Value>=String.Format("Page {0} of {1}", Format(Globals!PageNumber, "#,##0"), Format(Globals!TotalPages, "#,##0"))</Value></Textbox><Textbox Name="txtUserIDLabel"><Left>4in</Left><ZIndex>1</ZIndex><Width>2.375in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Color>#666666</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.21875in</Height><Value>="Prepared by: " &amp; Parameters!CRM_FullName.Value</Value></Textbox><Textbox Name="txtExecutionDateTimeLabel"><Left>0.25in</Left><Width>2.375in</Width><Style><PaddingLeft>2pt</PaddingLeft><PaddingBottom>2pt</PaddingBottom><FontWeight>700</FontWeight><FontSize>8pt</FontSize><Calendar>=Parameters!CRM_CalendarType.Value</Calendar><Format>=Parameters!CRM_FormatDate.Value + " " + Parameters!CRM_FormatTime.Value</Format><Color>#666666</Color><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop></Style><CanGrow>true</CanGrow><Height>0.21875in</Height><Value>=CDate(Microsoft.Crm.Reporting.RdlHelper.DateTimeUtility.ConvertUtcToLocalTime(DateTime.UtcNow, Parameters!CRM_UserTimeZoneName.Value))</Value></Textbox></ReportItems><Height>0.28125in</Height><PrintOnLastPage>true</PrintOnLastPage><PrintOnFirstPage>true</PrintOnFirstPage><Style><BackgroundColor>#deddcf</BackgroundColor></Style></PageFooter><TopMargin>0.5in</TopMargin><PageHeight>8.25in</PageHeight><CodeModules><CodeModule>Microsoft.Crm.Reporting.RdlHelper, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</CodeModule></CodeModules></Report>